<template>
  <div ref="barChartRef" class="main">柱状图</div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  mounted() {
    var chartDom = this.$refs.barChartRef
    var myChart = echarts.init(chartDom)
    var option

    option = {
      xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
        type: 'value'
      },

      grid: {
        show: false,
        top: '15%', // 一下数值可为百分比也可为具体像素值
        right: '5%',
        bottom: '10%',
        left: '10%'
      },
      series: [
        {
          data: [120, 200, 150, 80, 70, 110, 130],
          type: 'bar'
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>
<style scoped>
.main {
  width: 100%;
  height: 100%;
  background-color: var(--main-bg-color);
}
</style>
